package com.ophiux.FeverManagement.aplication.serviceImpl.wechat;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ophiux.FeverManagement.aplication.bean.wechat.getWechatInfoRequest;
import com.ophiux.FeverManagement.aplication.bean.wechat.getWechatInfoResponse;
import com.ophiux.FeverManagement.aplication.service.wechat.IGetWechatInfoService;
import com.ophiux.FeverManagement.domain.entity.WechatInfo;
import com.ophiux.FeverManagement.domain.repository.IWechatInfoRepositories;
import com.ophiux.micro.core.application.Result;
import com.ophiux.utils.common.ShiftUtils;
@Service
public class GetWechatInfoServiceImpl implements IGetWechatInfoService{
	@Autowired
	IWechatInfoRepositories wechatInfoRepositories;
	
	@Override
	public Result<getWechatInfoResponse> getWechatInfo(getWechatInfoRequest dto) {
		Result<getWechatInfoResponse> result = null;
		
		if(!dto.isParamValid()) {
			return Result.fail("", "必填参数未必填");
		}
		getWechatInfoResponse res = null;
		try {
			
			WechatInfo wechat = wechatInfoRepositories.getWechatInfoByNow();
			
			if(wechat != null) {
				res = (getWechatInfoResponse)ShiftUtils.objToNewObj(wechat, getWechatInfoResponse.class);
			}
			
			result = result.success(res);
		} catch (Exception e) {
			e.printStackTrace();
			result = Result.fail("","操作异常");
		}
		return result;
	}

}
